![]() |
PATH![]() |
![]() ![]() |
The Middle Element reference form specifies the middle object of a particular class in a container. This form is rarely used.
tell application "AppleWorks"
middle paragraph of text body of front document
end tell
middle item of {1, "doughnut", 33} --result: "doughnut"
middle item of {1, "doughnut", 22, 33} --result: "doughnut"
middle item of {1, "doughnut", 11, 22, 33} --result: 11
AppleScript calculates the middle object with the expression ((n + 1) div 2) , where n is the number of objects and div is the integer division operator. If there is an even number of objects in the container, the result is rounded down. For example, the middle word of a paragraph containing twenty words is the tenth word.